#pragma once

#include <QTimer>
#include <QVector>
#include <QStringList>
#include <memory>

#include "Object.h"
#include "ISimpleChannel.h"
#include "Typedefs.h"

class Machine;

class Action
{
public:
    Action();

public:
    virtual void Perform() = 0;
    virtual void Cancel();
	virtual void SetSpecific(const StringMap& properties);

public:
	void SetObject(ObjectPtr object);
    void SetMachine(Machine* machine);

    virtual ~Action();

private:
    virtual void CookObject();

protected:
    ObjectPtr   _object;
    Machine*    _machine;
};

class ResetAction : public Action
{
public:
    virtual void Perform();
};

class SendAction : public Action
{
public:
    void SetChannel(const QString& channel);
    virtual void Perform();
	virtual void SetSpecific(const StringMap& properties);

private:
    ISimpleChannelPtr _channel;
};

class AddCharAction : public Action
{
public:
    virtual void Perform();
};

class TimeoutAction : public Action
{
public:
    virtual void Perform();
    virtual void Cancel();

private:
    virtual void CookObject();

private:
    QTimer timer;
};

class CrcAction : public Action
{
public:
    virtual void Perform();
};

class LogAction : public Action
{
public:
    virtual void Perform();

private:
    virtual void CookObject();

private:
    typedef QList<QStringRef> StrRefList;
    StrRefList strings;
};

typedef std::tr1::shared_ptr<Action> ActionPtr;
typedef QVector<ActionPtr> ActionVector;